<template>
	<view>
		<view class="px-3 py-4" style="border-top: 1px solid #f6f6f6;">
			<view class="font-lg main-text-color-hei">几分钟了解谷雨颐嘉平台，我们为您的健康护航！</view>
			<view class="row j-start">
				<image src="../../static/litimg.jpg" style="width: 67upx;height: 62upx;"></image>
				<text>谷雨颐嘉平台 {{detail.uptime}}</text>
			</view>
			<view class="">
				<rich-text :nodes="detail.introduce|formatRichText"></rich-text>
			</view>
		</view>
		<view style="width:750upx;">
			<view style="width:700upx;margin:25upx;background-color:#49b813;color:#FFFFFF;">
				<view style="margin:25upx;">
					<view style="width:650upx;position:relative;height:80upx;text-align:center;padding-top:20upx;">
						<text style="border-top:1px solid #FFFFFF;color:#49b813;padding:0 80upx;position:absolute;top:50upx;left:0;">划线</text>
						<text style="font-size:36upx;font-weight:700;">温馨提示</text>
						<text style="border-top:1px solid #FFFFFF;color:#49b813;padding:0 80upx;position:absolute;top:50upx;right:0;">划线</text>
					</view>
					<view style="padding-bottom:30upx;">
						<block v-for="(item,index) in detail.attrarrs" :key="index">
						<view>
							<image style="width:30upx;height:20upx;" src="../../static/li.png"></image>
							<text style="margin-left:20upx;">{{item.attrname}}</text>
						</view>
						</block>
					</view>
				</view>
				
			</view>
		</view>
		<view class="row j-center">
			<navigator open-type="switchTab" url="../index/index" class="p-2">
				APP主页
			</navigator>
			<navigator  url="../CheckUp/CheckUp" class="p-2">
				线下门店
			</navigator>
			<navigator url="../counsel/counsel" class="p-2">
				健康资讯
			</navigator>
		</view>
	</view>
</template>

<script>
	import request from '@/common/lib/request.js'
	export default {
		data() {
			return {
				baseUrl:request.common.baseUrl,
				detail:''
			};
		},
		onLoad:function(){
			uni.request({
				url: request.common.baseUrl+'/api/index/systemSet',
				data: {},
				header: {
					'Content-Type':'application/json;charset=UTF-8',
					'Content-Type':'application/x-www-form-urlencoded'
				},
				success: (res) => {
					console.log(res)
					if(res.data.code==200){
						this.detail=res.data.data
					}
				}
			});
		},
		methods: {},
		filters: {
			/**
			 * 处理富文本里的图片宽度自适应
			 * 1.去掉img标签里的style、width、height属性
			 * 2.img标签添加style属性：max-width:100%;height:auto
			 * 3.修改所有style里的width属性为max-width:100%
			 * 4.去掉<br/>标签
			 * @param html
			 * @returns {void|string|*}
			 */
			formatRichText (html) { //控制小程序中图片大小
			    let newContent= html.replace(/<img[^>]*>/gi,function(match,capture){
			        match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
			        match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
			        match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
			        return match;
			    });
			    newContent = newContent.replace(/style="[^"]+"/gi,function(match,capture){
			        match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;');
			        return match;
			    });
			    newContent = newContent.replace(/<br[^>]*\/>/gi, '');
			    newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
			    return newContent;
			}	
		}
	};
</script>

<style></style>
